]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
calendar: Add "Do Not Disturb" switch
authorFlorian Müllner <fmuellner@gnome.org>
Fri, 4 May 2018 15:55:29 +0000 (17:55 +0200)
committerFlorian Müllner <florian.muellner@gmail.com>
Wed, 22 Jan 2020 21:55:28 +0000 (21:55 +0000)
We've had the ability to temporarily disable notification banners
all the way back to 3.0, but we stopped exposing it in the UI with
the 3.16 notification redesign. With the message list being more
concise nowadays and the "Clear" button reduced to a single icon,
we now have space for a "Do Not Disturb" switch again.

https://gitlab.gnome.org/GNOME/gnome-shell/issues/239

data/theme/gnome-shell-sass/widgets/_message-list.scss
js/ui/calendar.js

index 1b570c8ca4cc62f953b28ae8383d3bae8b6a3c36..bc80c3f2e844bffd3dfd56e14004b86f91865843 100644 (file)
   &:rtl {padding:0;}
 }
 
-// clear button
-.message-list-clear-button.button {
-  margin:$base_margin $base_margin*2;
+// do-not-disturb + clear button
+.message-list-controls {
+  margin: $base_margin $base_margin*2;
+  spacing: $base_spacing;
 }
 
 // message bubbles
index d0866ddf8dfd2797c05e340fda80c72f0e4e39ca..a5a763d59d099584fdbed5153f87ed0b208c3867 100644 (file)
@@ -7,6 +7,7 @@ const Main = imports.ui.main;
 const MessageList = imports.ui.messageList;
 const MessageTray = imports.ui.messageTray;
 const Mpris = imports.ui.mpris;
+const PopupMenu = imports.ui.popupMenu;
 const Util = imports.misc.util;
 
 const { loadInterfaceXML } = imports.misc.fileUtils;
@@ -1100,6 +1101,26 @@ class Placeholder extends St.BoxLayout {
     }
 });
 
+const DoNotDisturbSwitch = GObject.registerClass(
+class DoNotDisturbSwitch extends PopupMenu.Switch {
+    _init() {
+        this._settings = new Gio.Settings({
+            schema_id: 'org.gnome.desktop.notifications',
+        });
+
+        super._init(this._settings.get_boolean('show-banners'));
+
+        this._settings.bind('show-banners',
+            this, 'state',
+            Gio.SettingsBindFlags.INVERT_BOOLEAN);
+
+        this.connect('destroy', () => {
+            this._settings.run_dispose();
+            this._settings = null;
+        });
+    }
+});
+
 var CalendarMessageList = GObject.registerClass(
 class CalendarMessageList extends St.Widget {
     _init() {
@@ -1125,16 +1146,33 @@ class CalendarMessageList extends St.Widget {
         this._scrollView.set_policy(St.PolicyType.NEVER, St.PolicyType.AUTOMATIC);
         box.add_actor(this._scrollView);
 
+        let hbox = new St.BoxLayout({ style_class: 'message-list-controls' });
+        box.add_child(hbox);
+
+        hbox.add_child(new St.Label({
+            text: _('Do Not Disturb'),
+            y_align: Clutter.ActorAlign.CENTER,
+        }));
+
+        this._dndSwitch = new DoNotDisturbSwitch();
+        this._dndButton = new St.Button({
+            can_focus: true,
+            child: this._dndSwitch,
+        });
+        this._dndButton.connect('clicked', () => this._dndSwitch.toggle());
+        hbox.add_child(this._dndButton);
+
         this._clearButton = new St.Button({
             style_class: 'message-list-clear-button button',
             label: _('Clear'),
             can_focus: true,
+            x_expand: true,
             x_align: Clutter.ActorAlign.END,
         });
         this._clearButton.connect('clicked', () => {
             this._sectionList.get_children().forEach(s => s.clear());
         });
-        box.add_actor(this._clearButton);
+        hbox.add_actor(this._clearButton);
 
         this._placeholder.bind_property('visible',
             this._clearButton, 'visible',